package com.hua.api.core.util;

import java.text.DecimalFormat;

public class NumberUtil {

    private final static String DEFAULT_FORMAT = "0.00";

    public static Integer yuanToFen(Double yuan){
        if(null==yuan){
            return 0;
        }
        Double fen = yuan*100;
        return fen.intValue();
    }

    public static double formatMoney(double number, String format) {
        DecimalFormat df = new DecimalFormat(StringUtil.dealNull(format, DEFAULT_FORMAT));
        String str = df.format(number);
        return Double.valueOf(str);
    }

}
